
import request from '../utils/request'

/*获取所有角色*/ 
export function getRoles(){
  return request({
    method:'get',
    url:'roles'
  })
}
/*根据id获取角色*/
export function getRoleById(id){
  return request({
    method:'get',
    url:'roles/'+id
  })
}

/*添加角色*/
export function addRole(data){
  return request({
    method:'post',
    url:'roles',
    data
  })
} 

/*修改提交角色*/
export function updateRole(id,data){
  return request({
    method:'put',
    url:`roles/${id}`,
    data
  })
}
/*删除角色*/ 
export function deleteRole(id){
  return request({
    method:'delete',
    url:`roles/${id}`
  })
}




/*删除角色的某个权限*/
export function deleteOneRight(roleId,rightId){
  return request({
    method:'delete',
    url:`roles/${roleId}/rights/${rightId}`
  })
} 



/*分配权限*/
export function updateRight(roleId,data){
  return request({
    method:'post',
    url:`roles/${roleId}/rights`,
    data
  })
} 


